package deom7;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-04-10
 * Time: 6:43
 */
class ListNode{
    int val;
    ListNode next = null;
    public ListNode(int val){
        this.val = val;
    }
}
public class test01 {
   public ListNode FindKthToTail(ListNode pHead,int k){
        if(pHead == null || k == 0){
            return null;
        }
        ListNode fast = pHead;
        ListNode slow = pHead;
        while (k -1 > 0){
            fast =fast.next;
            if(fast == null){
                return null;
            }
            k--;
        }
        while (fast.next != null){
            slow = slow.next;
            fast = fast.next;
        }
        return  slow;
    }
}
